#优化了输入方式、数据类型转换和代码可读性
def calculate_bmr(gender, weight, height, age):
    if gender == "男":
        bmr = 13.7 * weight + 5.0 * height - 6.8 * age + 66
    elif gender == "女":
        bmr = 9.6 * weight + 1.8 * height - 4.7 * age + 655
    else:
        print("性别输入错误，请重新输入！")
        bmr = None
    return bmr

y_or_n = input('是否退出程序(y/n)？')
while y_or_n != 'y':
    gender, weight, height, age = input("请输入性别（男/女）、体重（公斤）、身高（厘米）和年龄[空格隔开]: ").split()
    weight, height, age = float(weight), float(height), int(age)
    bmr = calculate_bmr(gender, weight, height, age)
    if bmr is not None:
        print("BMR 数值为：{:.2f}".format(bmr))
    y_or_n = input('是否退出程序(y/n)？')